#!/usr/bin/python
# -*- coding: UTF-8 -*-

from kpautos.engine.case import Case
from kptest.config.enum import DeviceType, HostType, DeviceUtility


class TestCaseDemo(Case):
    """
        Name:
            TestCaseDemo
        Label:
            测试用例demo
        PreCondition:

        TestStep:
            1) API查询BMC版本信息
        ExpectedResult:
            A) 查询得到正确的BMC版本信息
        Parameters:

        Author:
            XXXXXX
        Last Modified:
            xxxx-xx-xx
        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        self.logger.info("Pre Test Case Start.... ")
        # get_device 实例化Device对象
        self.device_dut = self.resource.get_device(device_type=DeviceType.Server, utility=DeviceUtility.DUT)
        # get_api 实例化Api对象
        self.bmc_cli_api = self.device_dut.get_api(ns_name="BmcCli")
        self.bmc_host = self.device_dut.get_host(host_type=HostType.BMC)
        self.dpu_ipmi = self.device_dut.get_api("TestNs", api='kptest_extension_api', dispatcher=self.bmc_host)

    # 测试步骤
    def procedure(self):
        self.log_step("Step1: API查询BMC版本信息")
        version_from_cli = self.bmc_cli_api.cli_query_device_version()
        self.logger.info(version_from_cli)

    # 测试结束后恢复环境
    def post_test_case(self):
        pass